package com.avic.rong.activity.IncreaseTQ;

import android.content.Context;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

import com.avic.rong.BaseActivity;
import com.avic.rong.R;
import com.avic.rong.bean.increase_tp.IncreaseTpBean;

import java.io.Serializable;

import butterknife.BindView;

public class AuditSuccessActivity extends BaseActivity {

    @BindView(R.id.tv_name)
    TextView tv_name;
    @BindView(R.id.tv_identify)
    TextView tv_identify;
    @BindView(R.id.tv_address)
    TextView tv_address;
    @BindView(R.id.tv_phone)
    TextView tv_phone;
    @BindView(R.id.tv_bank)
    TextView tv_bank;
    @BindView(R.id.tv_blankNo)
    TextView tv_blankNo;
    @BindView(R.id.btn_update)
    Button btn_update;

    private StringBuffer stringBuffer = new StringBuffer();

    private IncreaseTpBean data;
    @Override
    protected int getContentViewId() {
        return R.layout.activity_audit_success;
    }

    @Override
    protected void initView() {
        tvTitle.setText("增票资质");

        data = (IncreaseTpBean) getIntent().getSerializableExtra("increaseSuccess");


        if (data!=null) {
            String companyName = data.getCompanyName();
            String regAddress = data.getRegAddress();
            String bank = data.getBank();
            String blankNo = data.getBlankNo();
            String identificationNumber = data.getIdentificationNumber();
            String regMobile = data.getRegMobile();

            tv_name.setText(getString(companyName));
            tv_address.setText(getString(regAddress));
            tv_bank.setText(getString(bank));
            tv_blankNo.setText(getString(blankNo));
            tv_identify.setText(getString(identificationNumber));
            tv_phone.setText(getString(regMobile));
        }
    }

    public String getString(String string){
        char[] chars = string.toCharArray();
        if (chars.length>3) {
            for (int i = 1; i < chars.length - 2; i++) {
                string.replace(chars[i], '*');
            }
        }
        return string;
    }


    @Override
    protected void addListener() {
        btn_update.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                upTp();//修改增票资质
            }
        });
    }
    private void upTp() {
        //跳转修改赠票资质
        Intent intent = UpIncreaseTpActivity.queryIntent(this);
        intent.putExtra("data", (Serializable) data);
        startActivity(intent);
        finish();
    }
    public static Intent queryIntent(Context context){
        Intent intent = new Intent(context, AuditSuccessActivity.class);
        return intent;
    }
}
